<?php
namespace App\Admin\Renderable;

use App\Models\Open\MicroApp;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;
use Dcat\Admin\Models\Administrator;

class MicroAppTable extends LazyRenderable
{

    public function grid(): Grid
    {
        return Grid::make(MicroApp::with(['sysAccount.platform', 'sysAccount.appType']), function (Grid $grid) {
            $grid->column('sysAccount.platform.name');
            $grid->column('sysAccount.appType.name');
            $grid->column('name');
            $grid->column('updated_at');

            $grid->quickSearch(['sysAccount.platform.name', 'sysAccount.appType.name', 'name']);

            $grid->paginate(10);
            $grid->disableActions();

            $grid->filter(function (Grid\Filter $filter) {
                $filter->like('sysAccount.platform.name')->width(4);
                $filter->like('sysAccount.appType.name')->width(4);
                $filter->like('name')->width(4);
            });
        });
    }
}
